package com.hnkywl.sts.entity.sys;

import com.hnkywl.sts.entity.BaseEntity;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.util.List;

/**
 * 权限
 * Created with IntelliJ IDEA.
 * User: jerry
 * Date: 13-3-3
 * Time: 下午10:17
 * To change this template use File | Settings | File Templates.
 */
@Entity
@Table(name = "T_SYS_QX")
@Where(clause = "deleted!='1'")
public class Qx extends BaseEntity {
    @Id
    @SequenceGenerator(name = "seqQx", allocationSize = 1, sequenceName = "SEQ_SYS_QX")
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seqQx")
    private Long id;
    /**
     * 权限名称
     */
    private String mc;
    /**
     * 角色
     */
    @ManyToMany(fetch = FetchType.LAZY,mappedBy = "qxList")
    private List<Js> jsList;
    /**
     * 菜单
     */
    @ManyToOne
    @JoinColumn(name = "CD_ID")
    @Where(clause = "deleted!='1'")
    @NotFound(action = NotFoundAction.IGNORE)
    private Cd cd;
    /**
     * 页面元素
     */
    @ManyToMany(fetch = FetchType.LAZY, targetEntity = Ymys.class)
    @JoinTable(name = "T_QX_YMYS",
            joinColumns = @JoinColumn(name = "QX_ID"),
            inverseJoinColumns = @JoinColumn(name = "YMYS_ID")
    )
    @Where(clause = "deleted!='1'")
    private List<Ymys> ymysList;
    /**
     * 功能操作
     */
    @ManyToMany(fetch = FetchType.LAZY, targetEntity = Gncz.class)
    @JoinTable(name = "T_QX_GNCZ",
            joinColumns = @JoinColumn(name = "QX_ID"),
            inverseJoinColumns = @JoinColumn(name = "GNCZ_ID")
    )
    @Where(clause = "deleted!='1'")
    private List<Gncz> gnczList;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getMc() {
        return mc;
    }

    public void setMc(String mc) {
        this.mc = mc;
    }

    public List<Js> getJsList() {
        return jsList;
    }

    public void setJsList(List<Js> jsList) {
        this.jsList = jsList;
    }

    public Cd getCd() {
        return cd;
    }

    public void setCd(Cd cd) {
        this.cd = cd;
    }

    public List<Ymys> getYmysList() {
        return ymysList;
    }

    public void setYmysList(List<Ymys> ymysList) {
        this.ymysList = ymysList;
    }

    public List<Gncz> getGnczList() {
        return gnczList;
    }

    public void setGnczList(List<Gncz> gnczList) {
        this.gnczList = gnczList;
    }


}
